﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

namespace S7Test
{
    class Program
    {
        static void Main(string[] args)
        {
            Socket client = new Socket(SocketType.Stream, ProtocolType.Tcp);
            client.Connect(IPAddress.Parse("127.0.0.1"), 102);
            client.Send(PlcHeader.Header1);
            var bytes = new byte[1024];
            int count1 = client.Receive(bytes);
            client.Send(PlcHeader.Header2);
            byte[] hand2 = new byte[1024];
            int count2 = client.Receive(hand2);
        }
    }

    class PlcHeader
    {
        public static byte[] Header1 = new byte[]
        {
            0x03,0x00,0x00,0x16,
            0x11,0xe0,0x00,0x00,
            0x00,0x01,0x00,0x00,
            0x01,0x0a,0xc1,0x02,
            0x01,0x02,0xc2,0x02,
            0x01,0x00
        };
        public static byte[] Header2 = new byte[]
        {
            0x30,0x00,0x00,0x19,
            0x02,0xf0,0x80,
            0x32,0x01,0x00,0x00,
            0x40,0x00,0x00,0x08,
            0x00,0x00,0xf0,0x00,
            0x00,0x01,0x00,0x01,
            0x01,0xe0,
        };
    }
}
